package com.shm.gbit;

import java.util.Scanner;

public class Main2 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String ns = input.nextLine();
        int n = Integer.parseInt(ns);
        String str = input.nextLine();
        String[] words = str.split(" ");
        int[] arr = new int[n];
        for (int i = 0; i < words.length; i++) {
            arr[i] = Integer.parseInt(words[i]);
        }
        int sum = 0;
        int[][] dp = new int[n][n+1];
        for (int i = n-1; i >=0 ; i--) {
            sum+=arr[i];
            for (int j = 1; j <=n ; j++) {
                if (i+2*j>=n){
                    dp[i][j]=sum;
                }else {
                    for (int k =1;k<=2*j;k++){
                        dp[i][j]=Math.max(dp[i][j],sum-dp[i+k][Math.max(j,k)]);
                    }
                }
            }
        }
        System.out.println(dp[0][1]);
    }
}
